home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d12 / asm_msc1.arc / MEMDRV.ASM < prev    next >
Assembly Source File  |  1988-11-20  |  14KB  |  357 lines

  1. title   ramdvr 01-01-84        [01-01-84] 
  2. ;------------------------------------------------------------------------------- 
  3. ; RAMDVR.SYS -- Modification to Dan O'Brien's excellent program by 
  4. ;               Tom Perry, CIS 70455,751 or FORUM ][ 305/772-4444. 
  5. ;               This modified version performs the same function described 
  6. ;               below.  The only difference is that it runs as a "device 
  7. ;               driver" on DOS 2.0 and up.  This means not only that it gets 
  8. ;               control earlier and thus works faster, but also that it will 
  9. ;               not cripple the system if you want to install a device that 
  10. ;               takes a fair amount of memory.  For instance, I had a virtual 
  11. ;               disk driver that uses 180K.  With switches set for 64K, it 
  12. ;               could not be installed.  To get around this with MORRAM.COM, 
  13. ;               you have to put logic in AUTOEXEC.BAT to switch between two 
  14. ;               CONFIG.SYS files; it can be done (I did it for a while), but 
  15. ;               it's messy and takes more disk space -- a LOT more if you're 
  16. ;               working with a hard file with its large allocation unit. 
  17. ;               To use this version, simply create a file on your boot disk 
  18. ;               named CONFIG.SYS containing the line DEVICE=RAMDVR.SYS 
  19. ;               and copy RAMDVR.SYS onto the boot disk.  If you already have 
  20. ;               a CONFIG file, enter DEVICE=RAMDVR.SYS as its first line. 
  21. ;               Set your switches for 64K, turn on the machine, and notice 
  22. ;               the difference.  To learn how it works, read Dan's description 
  23. ;               below. 
  24. ;               There IS a penalty for doing it this way: Part of the program 
  25. ;               remains permanently installed in the system as a device driver, 
  26. ;               eating up a few bytes of precious RAM.  I have left enough to 
  27. ;               keep the system from crashing if the device driver is driven 
  28. ;               again (for instance, by a MODE RAMCHECK command).  More bytes 
  29. ;               could be saved if you're willing to take that slight risk; 
  30. ;               probably the minimum you'd need to keep is the four bytes 
  31. ;               constituting the device driver chain at label "next_dev"; 
  32. ;               uncomment the indicated line if you want to try this. 
  33.  
  34.  
  35. ; MORERAM.COM - by Daniel M. O'Brien (v 1.0) 21 Dec 1983 
  36. ;             - freely adapted from a PC-WORLD User-to-User column program 
  37. ;               of the same name (object disassembled using ASMGEN) and from 
  38. ;               a program shown in a DR. DOBBS Journal article 
  39. ;               (16 bit Toolkit) called MEMSIZE. 
  40. ; This program has two (or three) purposes. 
  41. ;       1) Allow a PC to use more memory than is allowed via the motherboard 
  42. ;       memory switches (544 K bytes for the 64K motherboard and 640 K bytes 
  43. ;       for the newer 256K motherboard). And because of 1)... 
  44. ;       2) Allow faster power-up sequence by setting the motherboard memory 
  45. ;       switch settings to 64 K bytes installed. 
  46. ;       And as long as we are in the neighborhood... 
  47. ;       3) Patch the ROM BIOS data area to indicate that this PC has four 
  48. ;       floppy diskettes installed (instead of the normal two). This is for 
  49. ;       ram disk emulation programs that require the motherboard equipment 
  50. ;       options switch to be set to include the number of ram disks. 
  51. ;       This is most notably required by the AST RESEARCH ramdisk program 
  52. ;       called SUPERDRV. This code is commented out. To use it you must 
  53. ;       uncomment out the code and reassemble. Search for the string: 
  54. ;                       ;stub*** 
  55. ; Using MORERAM. 
  56. ;       First, copy MORERAM.COM to your boot device (floppy or fixed). 
  57. ;       Next, create or edit your AUTOEXEC.BAT file found on your 
  58. ;       boot device to include MORERAM as the **FIRST** program that 
  59. ;       will be executed. This is important as results are not guaranteed 
  60. ;       if MORERAM is not the first command executed at boot time. 
  61. ;       Next, open the covers of your PC and set the memory switches 
  62. ;       to indicate that your PC only has 64K. 
  63. ;       Now try rebooting your PC using the Alt-Ctrl-Del sequence. 
  64. ;       MORERAM will first display a hello banner and the amount of 
  65. ;       memory DOS thinks your PC has (should be 64K). Next, MORERAM 
  66. ;       will pause a second or two while it determines how much memory 
  67. ;       your PC really has. (It also clears this memory in the process 
  68. ;       to eliminate PARITY 2 errors later). 
  69. ;       Once the physical memory limit is determined, MORERAM will display 
  70. ;       that amount and then automatically re-boot. (Don't get excited, 
  71. ;       this won't loop indefinitely, because...) The next time MORERAM 
  72. ;       is again executed from your AUTOEXEC.BAT it will find that the amount 
  73. ;       of memory DOS thinks you have will be the same as that installed, and 
  74. ;       a reboot will be avoided! 
  75. ; I use this program on my PC that has 576K (64K + 512K) worth of memory. 
  76. ; Also, I have successfully tested it with 704K (64K + 512K + 128K) of memory, 
  77. ; but this requires placing memory into the semi-forbidden zone (segment A000) 
  78. ; designated by IBM as "reserved". But that's ok, as long as you don't install 
  79. ; memory beyond this into the B000 segment where monochrome and graphics display 
  80. ; memory live! 
  81. ; Questions or comments should be left for me (DAN OBRIEN) on Gene Plantz' 
  82. ; BBS in Chicago, IL (312-882-4227). I will attempt to fix bugs that may 
  83. ; crop up, but I make no guarantees. You use this at your own risk (just like 
  84. ; I do!). If you break something valuable, it's your own fault. 
  85. ;------------------------------------------------------------------------------- 
  86.  
  87.  
  88. lf      equ     0ah 
  89. cr      equ     0dh 
  90. ;initial values :       cs:ip   0000:0100 
  91. ;                       ss:sp   0000:ffff 
  92.  
  93. s0000   segment 
  94.         assume ds:s0000, ss:s0000 ,cs:s0000 ,es:s0000 
  95.         org     $+0000h 
  96. ;       device driver header and logic added 1-1-84 by Tom Perry. 
  97. next_dev        dd      -1 
  98.                 dw      8000h          ;char device 
  99. strategy        dw      dstrategy 
  100. interrupt       dw      dinterrupt 
  101. whatcall        db      'RAMCHECK'      ;name 
  102.  
  103. dstrategy       proc    far 
  104.  
  105.         mov     cs:rh_seg,es 
  106.         mov     cs:rh_off,bx            ;save ptr to request header 
  107.         ret 
  108.  
  109. dstrategy       endp 
  110.  
  111. rh_off  dw      0 
  112. rh_seg  dw      0 
  113.  
  114. dinterrupt      proc    far 
  115.  
  116.         cld 
  117.         push    ds 
  118.         push    es 
  119.         push    ax 
  120.         push    bx 
  121.         push    cx 
  122.         push    dx 
  123.         push    di 
  124.         push    si 
  125.  
  126.         mov     al,switch 
  127.         cmp     al,0ffh 
  128.         je      continue 
  129.         mov     al,0ffh 
  130.         mov     switch,al 
  131.  
  132.         call    memdrvr 
  133.  
  134.         mov     bx,rh_off 
  135.         mov     ax,rh_seg 
  136.         mov     es,ax           ;pt to req hdr 
  137.         mov     ds,ax 
  138.         mov     ax,offset last_place 
  139. ;*risk  mov     ax,offset strategy ;USE THIS LINE TO SAVE RAM AT SOME RISK! 
  140.         mov     14[bx],ax       ;set ending address 
  141.         mov     ax,cs 
  142.         mov     16[bx],ax       ; including segment 
  143. continue: 
  144.         mov     ax,0100h 
  145.         or      3[bx],ax        ;set device status as DONE with NO ERROR 
  146.  
  147.         pop     si 
  148.         pop     di 
  149.         pop     dx 
  150.         pop     cx 
  151.         pop     bx 
  152.         pop     ax 
  153.         pop     es 
  154.         pop     ds 
  155.  
  156.         ret 
  157.  
  158. switch  db      0,0,0           ;one time switch & bug protection 
  159. last_place db   'LAST PLACE' 
  160.  
  161. dinterrupt      endp 
  162.  
  163.  
  164. memdrvr proc    near 
  165.  
  166. ;       end of device driver modifications by Tom Perry 
  167. ;       (except as noted below). 
  168.  
  169. start:  jmp     begin 
  170.  
  171. hello   db      "Device driver to use MORE RAM than switches (v 1.1) ",cr,lf 
  172.         db      "by Daniel M. O'Brien and Tom Perry (1 Jan 1984)",cr,lf,lf,'$' 
  173. inmem   db      " Current memory is $" 
  174. kbytes  db      " K bytes. $" 
  175. findmem db      cr,lf," Physical memory is $" 
  176. analyze db      " Analyzing & Clearing...$" 
  177. reboot  db      " Re-Booting...",cr,lf,'$' 
  178. done    db      cr,lf," Memory size is set correctly.",cr,lf,'$' 
  179.  
  180. begin: 
  181.         mov     dx,offset hello         ; say hello 
  182.         mov     ah,9 
  183.         int     21h 
  184.  
  185.         mov     dx,offset inmem         ; how much memory? 
  186.         mov     ah,9 
  187.         int     21h 
  188.  
  189. ; next 3 lines of code added 1-1-84 by Tom Perry for device driver environment. 
  190.  
  191.         int     12h             ; ask bios how much memory 
  192.         mov     cl,6 
  193.         shl     ax,cl           ;shift left 6 times to look like PSP+2 
  194.  
  195. ;       mov     ax,ds:2         ; get top segment number from program prefix 
  196.  
  197.         push    ds              ; save ds for later 
  198.  
  199.         push    ax              ; save top segment number for later 
  200.         mov     cl,6            ; convert to K bytes 
  201.         shr     ax,cl 
  202.         call    decout          ; and display 
  203.  
  204.         mov     dx,offset kbytes        ; display "K bytes" 
  205.         mov     ah,9 
  206.         int     21h 
  207.  
  208.         mov     dx,offset analyze       ; display analyzing message 
  209.         mov     ah,9 
  210.         int     21h 
  211.  
  212.         xor     ax,ax           ; stop parity errors while we poke around 
  213.         out     0a0h,al 
  214.  
  215.         pop     ax              ; recover top segment number 
  216.  
  217. loop:   mov     bx,0            ; look into this 16 byte "segment" 
  218. ;       cmp     ax,0a000h       ; is ax = beginning of "reserved" addrs? 
  219.                                 ; stop at display memory instead! 
  220.         cmp     ax,0b000h       ; is ax = beginning of "reserved" addrs? 
  221.         je      ramend          ; yes, so end of ram 
  222.         mov     ds,ax           ; no, so use this as segment 
  223.         mov     [bx],ax         ; write contents of ax to ds:bx... 
  224.         mov     cx,[bx]         ;... and read it back to cx 
  225.         cmp     ax,cx           ; does data read = data written? 
  226.         jne     ramend          ; if it not, then ran out of ram! 
  227.  
  228.         mov     cx,8            ;    else - reset this 16 byte area 
  229.         mov     es,ax 
  230.         xor     ax,ax           ;      reset means 0000h 
  231.         xor     di,di 
  232.         rep     stosw           ;    to prevent parity errors when used 
  233.  
  234.         mov     ax,ds           ; copy ds to ax... 
  235.         inc     ax              ;... increment it... 
  236.         jmp     loop            ;... and loop 
  237.  
  238. ramend: 
  239.         mov     bx,ax           ; found real end of ram - save it 
  240.  
  241.         mov     al,80h          ; enable parity errors for the future 
  242.         out     0a0h,al 
  243.  
  244.         mov     ax,bx           ; convert segments to K bytes 
  245.         mov     cl,6 
  246.         shr     ax,cl 
  247.  
  248.         mov     bx,40h          ; point to bios data area 
  249.         mov     ds,bx 
  250.         mov     bx,13h          ; and to memory size word in particular 
  251.  
  252.         cmp     [bx],ax         ; same size? 
  253.         je      exit            ; yes-then we must have done this before 
  254.  
  255.         mov     [bx],ax         ; else - update and 
  256.         push    ax 
  257.  
  258. ; remove comments to patch equipment flag to indicate 4 floppies attached. 
  259. ; especially useful for AST RESEARCH's SUPERDRV. 
  260.  
  261. ;stub** mov     bx,10h          ; point to equipment flag 
  262. ;stub** mov     ax,[bx]         ; get equipment flag 
  263. ;stub** or      ax,00c0h        ; set installed floppy count to 4 
  264. ;stub** mov     [bx],ax         ; and restore to proper spot 
  265.  
  266.         pop     ax              ; get ds back but save ax on stack 
  267.         pop     ds 
  268.         push    ax 
  269.  
  270.         mov     dx,offset findmem       ; tell how much memory we found 
  271.         mov     ah,9 
  272.         int     21h 
  273.  
  274.         pop     ax              ; get K byte count 
  275.         call    decout 
  276.  
  277.         mov     dx,offset kbytes 
  278.         mov     ah,9 
  279.         int     21h 
  280.  
  281.         mov     dx,offset reboot        ; tell them about reboot 
  282.         mov     ah,9 
  283.         int     21h 
  284.  
  285.         int     19h             ; re-boot 
  286.  
  287. exit: 
  288.         pop     ds 
  289.         mov     dx,offset done 
  290.         mov     ah,9 
  291.         int     21h 
  292.  
  293. ; exit via return to caller instead of int 20h exit to DOS. 
  294. ; changed 1-1-84 by Tom Perry for device driver environment. 
  295.  
  296.         ret 
  297.  
  298.  
  299. ; quick and probably dirty - display decimal in ax routine 
  300.  
  301. decout: 
  302.         push    ax 
  303.         push    bx 
  304.         push    cx 
  305.         push    dx 
  306.  
  307.         xor     cx,cx           ;counter of digits 
  308.         mov     bx,10           ;divide by 10 for conversion 
  309.  
  310. decimal$loop: 
  311.         xor     dx,dx           ;clear for divide 
  312.         div     bx              ;get remainder and quotient 
  313.         add     dx,'00'         ;make remainder ascii 
  314.         push    dx              ;save it 
  315.         inc     cx              ;and count it 
  316.         or      ax,ax           ;out of digits? 
  317.         jnz     decimal$loop    ;no-loop on the decimal 
  318.  
  319. decimal$out: 
  320.         pop     dx              ;get digit 
  321.         mov     ah,2            ;print digit 
  322.         int     21h 
  323.         loop    decimal$out     ;and loop
  324.  
  325.         pop     dx
  326.         pop     cx
  327.         pop     bx
  328.         pop     ax
  329.         ret
  330.  
  331. memdrvr endp
  332.  
  333. s0000   ends
  334.  
  335.         end0000   ends
  336.  
  337.         end